use salvo::http::ParseError;
{{#if is_mongodb}}
use mongodb::bson::document::ValueAccessError as MongoBsonAccessError;
use mongodb::bson::oid::Error as MongoBsonOidError;
use mongodb::error::Error as MongoDbError;
{{/if}}
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
    #[error("error:`{0}`")]
    AnyHow(#[from] anyhow::Error),
    #[error("http::ParseError:`{0}`")]
    ParseError(#[from] ParseError),
    {{#if is_sqlx}}
    #[error("sqlx::Error:`{0}`")]
    SqlxError(#[from] sqlx::Error),
    {{/if}}
    {{#if is_sea_orm}}
    #[error("sea_orm::DbErr:Error:`{0}`")]
    DbErr(#[from] sea_orm::DbErr),
    {{/if}}
    {{#if is_diesel}}
    #[error("diesel::result::Error:`{0}`")]
    DieselErr(#[from] diesel::result::Error),
    {{/if}}
    {{#if is_rbatis}}
    #[error("rbatis::Error:`{0}`")]
    RbatisErr(#[from] rbatis::Error),
    {{/if}}
    {{#if is_mongodb}}
    #[error("mongodb::error::Error:`{0}`")]
    MongoDbErr(#[from] MongoDbError),
    #[error("mongodb::bson::document::ValueAccessError:`{0}`")]
    MongoBsonAccessError(#[from] MongoBsonAccessError),
    #[error("mongodb::bson::oid::Error`{0}`")]
    MongoBsonOidError(#[from] MongoBsonOidError),
    {{/if}}
    {{#if need_db_conn}}
    #[error("ValidationError:`{0}`")]
    ValidationError(#[from] validator::ValidationErrors),
    {{/if}}
}